package com.cxc.news.service.Impl;


import com.cxc.news.dao.UserDao;
import com.cxc.news.pojo.User;
import com.cxc.news.service.UserService;
import com.cxc.news.utils.MD5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;

    @Override
    public User checkUser(String username, String password) {
        return userDao.selectUserByNameAndPassword(username, MD5Utils.code(password));
    }

    @Override
    public User getUserById(Long id) {
        return userDao.selectUserById(id);
    }

    @Override
    public User getUserByName(String username) {
        return userDao.selectUserByUsername(username);
    }

    @Override
    public void addUser(User user) {
        userDao.insertUser(user);
    }

    @Override
    public List<User> getUserList() {
        return userDao.selectUserList();
    }

    @Override
    public void deleteUser(Long id) {
        userDao.deleteUser(id);
    }


}
